﻿using System;
using System.IO;
namespace Logger
{
    public class HtmlLogger : ILogger
    {
        private readonly String _logPath;

        public HtmlLogger(String logPath)
        {
            _logPath = logPath;
        }

        public void WriteRecord(string record)
        {
            record = record + "<br>";
            var file = new StreamWriter(_logPath, true);
            file.WriteLine(record);
            file.Close();
        }

        public string ReadAllRecords()
        {
            try
            {
                var file = new StreamReader(_logPath);
                var result = file.ReadToEnd();
                file.Close();
                return result;
            }
            catch (Exception)
            {
                return null;
            }
        }
    }
}
